ACTOR DualMP40 : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Mauser9mm"
	Weapon.AmmoType2 "DualMP40Ammo"
	Obituary "%o was shot down by %k's SMG."
    AttackSound "None"
    +QUIET
	Inventory.PickupMessage ""
	Inventory.ForbiddenTo Sorcerer, Paladin, Corvus
	+WEAPON.NOAUTOAIM
    //+WEAPON.NOAUTOFIRE
    +FORCEXYBILLBOARD
	+WEAPON.NO_AUTO_SWITCH
	Scale 0.9
	States
	{
	NoAmmoOnSecondGun:
		MP42 A 2
	Ready3:
	Ready:
	ReadyLoop:
        MP42 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP42 A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		MP42 A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		MP42 A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        MP42 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		MP42 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		MP42 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		MP42 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		MP42 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		MP42 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		Loop
		
	DualWield:
		MP42 F 1
		MP42 A 0 A_Takeinventory("StartDualWield",1)
		MP42 A 0 A_SelectWEapon("MP40")
		Goto Ready		
		
	Deselect:
        MP42 F 1
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
		MP42 A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 1 A_Lower
		Wait
		
	Select:
		MP42 A 0 A_Takeinventory("HasBarrel",1)
		TNT1 A 1
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAA 0 A_Raise
		Goto SelectAnimation
		
		
	SelectAnimation:
		TNT1 A 1
	    MP42 A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
        MP42 A 0 A_PlaySound("CLIPIN")
        MP42 F 1
		MP42 A 0 A_Takeinventory("StartDualWield",1)
        MP42 A 0 A_GunFlash
		Goto Ready

	Altfire:
    Fire:
        MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
		MP42 A 0 A_PlaySound("FARSHT", 6)
        MP42 A 0 A_PlaySound("pfire", 1)
		MP42 A 0 A_ZoomFactor(0.99)
		//MP42 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		MP42 B 1 BRIGHT A_FireBullets (4, 3, -1, 15, "WeakPuff", FBF_NORANDOM)
		MP42 A 0 A_ZoomFactor(1.0)
        MP42 C 1 A_FireCustomMissile("DecorativeTracer", random(-6,3), 0, 5, 0)
		MP42 A 0 A_Takeinventory("MP40Ammo",1)
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,6,-2)
		
		
		MP42 A 0 A_JumpIfInventory("MP40Ammo",1,1)//Checks if single gun is not depleted
        Goto NoAmmoOnSecondGun
		
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,1)
        Goto NoAmmo
		
		MP42 A 0 A_PlaySound("FARSHT", 6)
        MP42 A 0 A_PlaySound("pfire", 1)
		MP42 A 0 A_ZoomFactor(0.99)
		//MP42 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		MP42 D 1 BRIGHT A_FireBullets (4, 3, -1, 15, "WeakPuff", FBF_NORANDOM)
		MP42 A 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", random(-3,6), 0, -5, 0)
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
        MP42 E 1
		MP42 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,-8,-2)
		MP42 A 0 A_ReFire
		MP42 A 1 A_WeaponReady(1)
		MP42 A 7 A_WeaponReady(1)
		Goto Ready3
		
		
	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		MP42 A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		RIFG A 0 A_JumpIfInventory("Mauser9mm",1,"Reload")
		RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
		Goto Ready3
	
    Reload:
		MP42 A 1
		MP42 A 0 A_Takeinventory("ADSmode",1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",64,"Ready")

        MP42 A 0 A_JumpIfInventory("Mauser9mm",1,3)
        Goto NoAmmo
        TNT1 AAA 0
		MP42 A 0 A_Takeinventory("Zoomed",1)
        MP42 A 0 A_ZoomFactor(1.0)
		MP42 A 0 A_GiveInventory ("Pumping", 1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		RIFR C 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		MP42 F 1
		TNT1 A 5
		MP42 A 0 A_PlaySound("reload")
        MP4R ABCDEF 1 
		MP42 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		MP42 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
        MP4R GGGGGGGGGGGGGGGFEDDDCCBA 1
		TNT1 A 5
		
		MP42 A 0 A_PlaySound("reload")
        MP42 A 0 A_PlaySound("reload")
        MP2R ABCDEF 1 
		MP42 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		MP42 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
        MP2R GGGGGGGGGGGGGGGFEDDDCCBA 1
		
		MP42 F 1
		
	TurboReload:
		MP42 A 0 A_Takeinventory("HasUnloaded",1)
        SM2S BA 0
        Goto InsertBullets
		
	InsertBullets:
		TNT1 AAAA 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",64,15)
		MP42 A 0 A_JumpIfInventory("Mauser9mm",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		MP42 A 0 A_Giveinventory("MP40Ammo",1)
		MP42 A 0 A_Giveinventory("DualMP40Ammo",1)
		MP42 A 0 A_Takeinventory("Mauser9mm",1)
		Goto InsertBullets
		
		TNT1 AAAAAAAAAA 0
		MP42 A 0 A_Takeinventory("Reloading",1)
		
		MP42 A 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		MP42 A 0 A_Takeinventory("Reloading",1)
		
		MP42 A 0 A_Refire
        Goto Ready
		
	
 	 Unload:
		MP42 A 1
		MP42 A 0 A_Takeinventory("ADSmode",1)
		MP42 A 0 A_Takeinventory("Unloading",1)
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,3)
		Goto NoAmmo
        TNT1 AAA 0

		MP42 A 0 A_Takeinventory("Zoomed",1)
        MP42 A 0 A_ZoomFactor(1.0)
		MP42 A 0 A_GiveInventory ("Pumping", 1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_PlaySound("reload")
		MP42 A 0 A_Giveinventory("HasUnloaded",1)
        MP4R ABCCDDDEFG 1
		MP2R ABCCDDDEFG 1
		
	RemoveBullets:
		TNT1 AAAA 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		MP42 A 0 A_Takeinventory("MP40Ammo",1)
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_Giveinventory("Mauser9mm",1)
		Goto RemoveBullets
		
		TNT1 AAAAAAAAAA 0
		MP42 A 0 A_Takeinventory("Reloading",1)
		
		MP42 A 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		MP42 A 0 A_Takeinventory("Reloading",1)
		
		MP42 A 0 A_Refire
        Goto Ready
	
	
	Spawn:
		SMGZ A -1
		Stop
		
		
	Steady:
		TNT1 A 1
		Goto Ready	
	}
}